<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="mall/advert/include::header"></head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css">
<link rel="stylesheet" type="text/css" href="/css/plugins/layui/layui.css"/>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>广告添加</h5>
					</div>
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="signupForm">
							<div class="form-group">
								<label class="col-sm-3 control-label">标题:</label>
								<div class="col-sm-8">
									<input id="advname" name="advname" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">类型:</label>
								<div class="col-sm-8">
									<select id="type" name="type" data-placeholder="" class="form-control chosen-select" tabindex="2">
										<option th:each="item: ${baTypes}" th:text="${item.name}" th:value="${item.typeId}"></option>
									</select>
								</div>
							</div>

							<input type="hidden"  id="centreId" name="centreId" th:value="${centreId}" th:if="${flag} == '1'">
							<input type="hidden" id="productLinkPrefix" th:value="${productLinkPrefix}">
							<input type="hidden" id="productId"  name="productId">
							<input type="hidden" id="categoryLinkPrefix" th:value="${categoryLinkPrefix}">
							<div class="form-group" th:if="${flag} == '0'">
								<label class="col-sm-3 control-label">商户:</label>
								<div class="col-sm-8">
								 	<select name="centreId" class="form-control" type="text">
										<option value="" selected="selected">--请选择--</option>
										<option th:each="item: ${centreList}" th:text="${item.name}" th:value="${item.centreId}"></option>
									</select>
								  <!-- <select name="centreId" class="form-control" type="text" multiple data-live-search="true"
						              data-actions-box="true">
										<option th:each="item: ${centreList}" th:text="${item.name}" th:value="${item.centreId}"></option>
									</select>-->
								</div>
							</div>

							<div class="form-group" th:if="${showTeam} == 1">
								<label class="col-sm-3 control-label">选择门店:</label>
								<div class="col-sm-8">
									<select data-placeholder="" class="form-control chosen-select" id="teamId" name="teamId">
										<option value="0">选择门店</option>
										<option th:each="item: ${teamList}" th:text="${item.tXiaoqu+ +item.id}"
												th:value="${item.id}"></option>
									</select>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">跳转类型:</label>
								<div class="col-sm-8">
									<label class="radio-inline">
										<input type="radio" name="mediaType" value=""/>无
									</label>
									<label class="radio-inline">
										<input type="radio" name="mediaType" value="H5"/>H5
									</label>
									<label class="radio-inline">
										<input type="radio" name="mediaType" value="product"/>商品
									</label>
									<label class="radio-inline">
										<input type="radio" name="mediaType" value="otherWxxcx"/>小程序
									</label>
									<label class="radio-inline">
										<input type="radio" name="mediaType" value="order"/>点单
									</label>
									<label class="radio-inline">
										<input type="radio" name="mediaType" value="scanCode"/>扫码
									</label>
									<label class="radio-inline">
										<input type="radio" name="mediaType" value="xcxUrl"/>小程序URL
									</label>
									<label class="radio-inline">
										<input type="radio" name="mediaType" value="xcxBottomUrl"/>小程序底部菜单URL
									</label>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">地区:</label>
								<div class="col-sm-8">
									<div class="gg-formDetail gg-font0" data-toggle="distpicker">
										<div class="gg-area">
											<select class="form-control" id="province" name="province" :data-province="----选择省----">
											</select>
										</div>
										<div class="gg-area">
											<select class="form-control" id="city" name="city" :data-city="----选择市----">
											</select>
										</div>
										<div class="gg-area">
											<select class="form-control" id="area" name="area" :data-district="----选择区----">
											</select>
										</div>
									</div>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">图片:</label>
								<div class="col-sm-6">
									<input id="thumb" name="thumb" class="form-control" type="text" onblur="onThumbBlur()">
								</div>
								<div class="col-sm-2">
									<button type="button" onclick="onSelectImgBtnClick('thumb','thumbImg')" class="btn btn-primary"><i class="fa fa-check"></i>选择图片</button>
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-8">
									<label class="col-sm-5 control-label">-</label>
									<img class="img-responsive" id="thumbImg" src="" style="max-width: 30%">
								</div>
							</div>


							<div class="form-group">
								<label class="col-sm-3 control-label">链接:</label>
								<div class="col-sm-8">
									<input id="link" name="link" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">链接到商品:</label>
								<div class="col-sm-8">
									<input id="productName" name="productName" class="form-control" type="text" readonly onclick="linkToProduct()">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">风格:</label>
								<div class="col-sm-8">
									<label class="radio-inline"> <input id="style0" type="radio"
																		name="style"
																		value="0"/>banner图</label>
									<label class="radio-inline"> <input id="style1" type="radio"
																		name="style"
																		value="1"/>幻灯片</label>
									<label class="radio-inline"> <input id="style2" type="radio"
																		name="style"
																		value="2"/>分类专区</label>
									<label class="radio-inline"> <input id="style3" type="radio"
																		name="style"
																		value="3"/>秒杀专区</label>
									<label class="radio-inline"> <input id="style4" type="radio"
																		name="style"
																		value="4"/>活动专区</label>
									<label class="radio-inline"> <input id="style5" type="radio"
																		name="style"
																		value="5"/>广告位专区</label>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">链接到分类:</label>
								<div class="col-sm-8">
									<select data-placeholder="" class="form-control chosen-select" tabindex="2" onchange="categoryChange(this)">
										<option value="" selected="selected">选择分类</option>
										<option th:each="item: ${categoryList}" th:text="${item.name}" th:value="${item.id}"></option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">所属品牌:</label>
								<div class="col-sm-8">
									<select data-placeholder="" class="form-control chosen-select" tabindex="2" name="brandId" id="brandId">
										<option value="" selected="selected">选择品牌</option>
										<option th:each="item: ${reservationBrandCategoryList}" th:text="${item.name}" th:value="${item.id}"></option>
									</select>
								</div>
							</div>


							<div class="form-group" id='shangjiadiv'>
								<label class="col-sm-3 control-label"
									   for="form-field-1"> 上架时间范围： </label>
								<div class="col-sm-8">
									<div class="col-sm-4 col-xs-6">
										<input type="text" name="upStartTime" id="upStartTime"
											   placeholder="请选择日期时间"
											   readonly="readonly" class="layui-input form-control"
											   style="padding-left: 12px;">
									</div>
									<div class="col-sm-4 col-xs-6">
										<input type="text" name="upEndTime" id="upEndTime"
											   placeholder="请选择日期时间"
											   readonly="readonly" class="layui-input form-control"
											   style="padding-left: 12px;">
									</div>
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">排序:</label>
								<div class="col-sm-8">
									<input id="displayorder" name="displayorder" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">是否显示:</label>
								<div class="switch onoffswitch col-sm-1">
									<div class="onoffswitch">
										<input type="checkbox"  class="onoffswitch-checkbox" value="1" checked="" id="enabled" name="enabled">
										<label class="onoffswitch-label" for="enabled">
											<span class="onoffswitch-inner"></span>
											<span class="onoffswitch-switch"></span>
										</label>
									</div>
								</div>
							</div>

							<div class="form-group text-center">
								<div class="col-sm-8 col-sm-offset-2">
									<button type="submit" class="btn btn-primary"><i class="fa fa-check"></i>提交</button>
									<div class="btn btn-danger" onclick="closeDow()"><i class="fa fa-remove"></i> 关闭</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:include="mall/advert/include::footer"></div>
	<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/i18n/defaults-*.min.js"></script>
	<script type="text/javascript" src="/js/appjs/mall/advert/add.js"></script>
	<script type="text/javascript" src="/js/plugins/layui/layui.js"></script>
	<script type="text/javascript">
		function closeDow() {
			var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
			parent.layer.close(index);
		}
		   $('#centreId').selectpicker({
		        'selectedText': 'cat',
		   	    'noneSelectedText':'请选择商户',
		        'deselectAllText':'全不选',
		        'selectAllText': '全选',
		    });
        layui.use('laydate', function(){
            var laydate = layui.laydate;
            laydate.render({
                elem: '#timestart'
                ,type: 'datetime'
            });

            laydate.render({
                elem: '#timeend'
                ,type: 'datetime'
            });
            laydate.render({
                elem: '#upStartTime' , type: 'datetime'
            });

            laydate.render({
                elem: '#upEndTime' , type: 'datetime'
            });
        })
 

        $(function() {
            // 设置默认限卖时间
            var date = new Date();
            var year = date.getFullYear();
            var mon=date.getMonth()+1 < 10 ? "0"+ date.getMonth()+1:date.getMonth()+1;
            var da=date.getDate() < 10 ? "0"+ date.getDate():date.getDate();
            var h=date.getHours() < 10 ? "0"+ date.getHours():date.getHours();
            var m=date.getMinutes() < 10 ? "0"+ date.getMinutes():date.getMinutes();

            date.setDate(date.getDate()+1);
            var endyear = date.getFullYear();
            var endmon=date.getMonth()+1 < 10 ? "0"+ date.getMonth()+1:date.getMonth()+1;
            var endda=date.getDate() < 10 ? "0"+ date.getDate():date.getDate();
            var endh=date.getHours() < 10 ? "0"+ date.getHours():date.getHours();
            var endm=date.getMinutes() < 10 ? "0"+ date.getMinutes():date.getMinutes();
            $("#timestart").val(year+"-"+mon+"-"+da+" 20:30:00");
            $("#timeend").val(endyear+"-"+endmon+"-"+endda+" 20:00:00");
            $("#upStartTime").val(year+"-"+mon+"-"+da+" 20:00:00");
            $("#upEndTime").val(endyear+"-"+endmon+"-"+endda+" 20:00:00");
        })
	</script>
</body>

</html>
